# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=peepdf
pkgname=('python2-peepdf' 'peepdf')
pkgver=0.4.2
pkgrel=9
groups=('blackarch' 'blackarch-forensic' 'blackarch-malware')
pkgdesc='A Python tool to explore PDF files in order to find out if the file can be harmful or not.'
arch=('any')
url='http://eternal-todo.com/tools/peepdf-pdf-analysis-tool'
license=('GPL3')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${pkgbase::1}/$pkgbase/$pkgbase-$pkgver.tar.gz"
        'setup.py.patch')
sha512sums=('7a603719c07befc45f0e89da0c36d48a459452160939e7d5ba59adf3f1a67fa82fa69ee5728558632ccf9fbdd60055184deb86b8748383e6ab17c008aa4865ba'
            'cdd0be094ba3ba1731bc03b09a6666b926b1d10e6d0f198062f421bd58e5b6debc3e203c5f71f0d6f0773be66376228cd0354c556481ada6d44d3248d9ce575b')

prepare() {
  cd "$pkgbase-$pkgver"

  patch -p2 < ../setup.py.patch

  cd "$srcdir"

  cp -a "$pkgbase-$pkgver"{,-2}
}

build() {
  cd "$pkgbase-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$pkgbase-$pkgver"

  python setup.py build
}

package_python2-peepdf() {
  depends=('python2' 'python2-jsbeautifier' 'python2-pylibemu' 'python2-future'
           'python2-pythonaes' 'python2-colorama' 'python2-pillow6')

  cd "$pkgbase-$pkgver-2"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  for i in "$pkgdir/usr/bin/"*; do
    mv $i "${i}2"
  done
}

package_peepdf() {
  depends=('python' 'python-jsbeautifier' 'python-pylibemu' 'python-future'
           'python-pythonaes' 'python-colorama' 'python-pillow6')

  cd "$pkgbase-$pkgver"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

